import json
from fastapi import APIRouter, HTTPException,Depends
from typing import Optional, Any
from pydantic import BaseModel
from sqlalchemy.orm import Session
from app.common.response.response_schema import response_base

# status service
from app.api.service import sche_service
from app.schemas.job import ReqCreateJob

from app.schemas.sche import ReqJob


# 创建status router路由
sche_router = APIRouter()



@sche_router.get('/')
async def get_schedulers():
    res =  await sche_service.get_schedulers()
    return response_base.response_200(msg='查询成功',data=res)




@sche_router.get('/{job_id}')
async def get_schedulers(job_id:str):
    res = await sche_service.get_scheduler_by_id(job_id)
    return response_base.response_200(msg='查询成功',data=res)





@sche_router.post("/add",summary='增加定时')
async def add_schedulers(params:ReqCreateJob):
    await sche_service.add_scheduler(params)
    return response_base.response_200(msg='增加成功')




@sche_router.delete("/delete",summary='删除定时')
async def delete_schedulers(job_id:str):
    await sche_service.del_scheduler(job_id)
    return response_base.response_200(msg='删除成功')



